package programs;

import java.util.ArrayList;
import program.*;
import traces.*;

public class ATM_Factory {		

	public static Main create(){
		int i= 0;
	    ArrayList<Actor> actors= new ArrayList<Actor>();
		
		                                  
		ObjectClass ihmClass=new ObjectClass("ihm");
		Actor ihm = new Actor("ihm", ihmClass);   
		actors.add(ihm);                                                 
		                                  
		ObjectClass accountClass=new ObjectClass("account");
		Actor account = new Actor("account", accountClass);   
		actors.add(account);                                                 
		                                  
		ObjectClass bankClass=new ObjectClass("bank");
		Actor bank = new Actor("bank", bankClass);   
		actors.add(bank);                                                 
		                                  
		ObjectClass atmClass=new ObjectClass("atm");
		Actor atm = new Actor("atm", atmClass);   
		actors.add(atm);                                                 
		                                  
		ObjectClass consoClass=new ObjectClass("conso");
		Actor conso = new Actor("conso", consoClass);   
		actors.add(conso);                                                 
		                                  
		ObjectClass accGenClass=new ObjectClass("accGen");
		Actor accGen = new Actor("accGen", accGenClass);   
		actors.add(accGen);                                                 
		
		/* NESTED CALL: displayMainScreen_id1 */
		BlockList bloc_displayMainScreen_id1= new BlockList();
		
		/* NESTED CALL: insertCard_id2 */
		BlockList bloc_insertCard_id2= new BlockList();
		
		/* NESTED CALL: checkCard_id3 */
		BlockList bloc_checkCard_id3= new BlockList();
		
		Call checkAccount_id4 = new Call(new Statement("S" + i++,atm,new Method("checkAccount",new ArrayList<ObjectInstance>(),atmClass),atm));        
		
		/* add(s) for checkCard_id3 */
		bloc_checkCard_id3.add(checkAccount_id4);
		
		// TODO ca erreur signaler Jean a verifier
		//Call checkCard_id3 = new Call(new Statement("S" + i++,atm,new Method("checkCard",new ArrayList<ObjectInstance>(),atmClass),atm), bloc_checkCard);
		Call checkCard_id3 = new Call(new Statement("S" + i++,atm,new Method("checkCard",new ArrayList<ObjectInstance>(),atmClass),atm), checkAccount_id4);
		
		/* ALTERNATIVE: alt_id5 */
		BlockList bloc_alt_id5_conseq = new BlockList();
		
		Call ejectCard_id6 = new Call(new Statement("S" + i++,atm,new Method("ejectCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		Call requestTakeCard_id7 = new Call(new Statement("S" + i++,atm,new Method("requestTakeCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		// add(s) for bloc_alt_id5_conseq
		bloc_alt_id5_conseq.add(ejectCard_id6);
		bloc_alt_id5_conseq.add(requestTakeCard_id7);
		
		BlockList bloc_alt_id5_alter = new BlockList();
		
		Call requestPass_id8 = new Call(new Statement("S" + i++,atm,new Method("requestPass",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		/* ALTERNATIVE: alt_id9 */
		BlockList bloc_alt_id9_conseq = new BlockList();
		
		Call cancelUponPasswordRequest_id10 = new Call(new Statement("S" + i++,ihm,new Method("cancelUponPasswordRequest",new ArrayList<ObjectInstance>(),atmClass),atm));        
		
		Call ackCancelUponPasswdRequest_id11 = new Call(new Statement("S" + i++,ihm,new Method("ackCancelUponPasswdRequest",new ArrayList<ObjectInstance>(),atmClass),atm));        
		
		Call ejectCard_id12 = new Call(new Statement("S" + i++,atm,new Method("ejectCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		Call requestTakeCard_id13 = new Call(new Statement("S" + i++,atm,new Method("requestTakeCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		// add(s) for bloc_alt_id9_conseq
		bloc_alt_id9_conseq.add(cancelUponPasswordRequest_id10);
		bloc_alt_id9_conseq.add(ackCancelUponPasswdRequest_id11);
		bloc_alt_id9_conseq.add(ejectCard_id12);
		bloc_alt_id9_conseq.add(requestTakeCard_id13);
		
		BlockList bloc_alt_id9_alter = new BlockList();
		
		/* LOOP: loop_id14 */
		BlockList bloc_loop_id14 = new BlockList();
		
		/* NESTED CALL: enterPassword_id15 */
		BlockList bloc_enterPassword_id15= new BlockList();
		
		Call isPasswordAvailable_id16 = new Call(new Statement("S" + i++,atm,new Method("isPasswordAvailable",new ArrayList<ObjectInstance>(),bankClass),bank));        
		
		/* add(s) for enterPassword_id15 */
		bloc_enterPassword_id15.add(isPasswordAvailable_id16);
		
		// TODO ca erreur signaler Jean a verifier
		//Call enterPassword_id15 = new Call(new Statement("S" + i++,ihm,new Method("enterPassword",new ArrayList<ObjectInstance>(),atmClass),atm), bloc_enterPassword);
		Call enterPassword_id15 = new Call(new Statement("S" + i++,ihm,new Method("enterPassword",new ArrayList<ObjectInstance>(),atmClass),atm), isPasswordAvailable_id16);
		
		/* ALTERNATIVE: alt_id17 */
		BlockList bloc_alt_id17_conseq = new BlockList();
		
		Call ejectCard_id18 = new Call(new Statement("S" + i++,atm,new Method("ejectCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		Call requestTakeCard_id19 = new Call(new Statement("S" + i++,atm,new Method("requestTakeCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		// add(s) for bloc_alt_id17_conseq
		bloc_alt_id17_conseq.add(ejectCard_id18);
		bloc_alt_id17_conseq.add(requestTakeCard_id19);
		
		BlockList bloc_alt_id17_alter = new BlockList();
		
		/* NESTED CALL: withdrawMoney_id20 */
		BlockList bloc_withdrawMoney_id20= new BlockList();
		
		/* NESTED CALL: getMoney_id21 */
		BlockList bloc_getMoney_id21= new BlockList();
		
		/* NESTED CALL: remove_id22 */
		BlockList bloc_remove_id22= new BlockList();
		
		Call getSolde_id23 = new Call(new Statement("S" + i++,bank,new Method("getSolde",new ArrayList<ObjectInstance>(),accountClass),account));        
		
		/* OPTION: opt_id24 */
		BlockList bloc_opt_id24 = new BlockList();
		
		Call setSolde_id25 = new Call(new Statement("S" + i++,bank,new Method("setSolde",new ArrayList<ObjectInstance>(),accountClass),account));        
		
		Call getSolde_id26 = new Call(new Statement("S" + i++,bank,new Method("getSolde",new ArrayList<ObjectInstance>(),accountClass),account));        
		
		//add(s) for opt_id24
		bloc_opt_id24.add(setSolde_id25);
		bloc_opt_id24.add(getSolde_id26);
		
		Opt opt_id24 = new Opt(bloc_opt_id24);
		
		/* add(s) for remove_id22 */
		bloc_remove_id22.add(getSolde_id23);
		bloc_remove_id22.add(opt_id24);
		
		// TODO ca erreur signaler Jean a verifier
		//Call remove_id22 = new Call(new Statement("S" + i++,atm,new Method("remove",new ArrayList<ObjectInstance>(),bankClass),bank), bloc_remove);
		Call remove_id22 = new Call(new Statement("S" + i++,atm,new Method("remove",new ArrayList<ObjectInstance>(),bankClass),bank), bloc_remove_id22);
		
		/* ALTERNATIVE: alt_id27 */
		BlockList bloc_alt_id27_conseq = new BlockList();
		
		Call ejectCard_id28 = new Call(new Statement("S" + i++,atm,new Method("ejectCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		Call requestTakeCard_id29 = new Call(new Statement("S" + i++,atm,new Method("requestTakeCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		// add(s) for bloc_alt_id27_conseq
		bloc_alt_id27_conseq.add(ejectCard_id28);
		bloc_alt_id27_conseq.add(requestTakeCard_id29);
		
		BlockList bloc_alt_id27_alter = new BlockList();
		
		Call ejectCardUponTooHighWithdraw_id30 = new Call(new Statement("S" + i++,atm,new Method("ejectCardUponTooHighWithdraw",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		Call requestTakeCard_id31 = new Call(new Statement("S" + i++,atm,new Method("requestTakeCard",new ArrayList<ObjectInstance>(),ihmClass),ihm));        
		
		// add(s) for bloc_alt_id27_alter
		bloc_alt_id27_alter.add(ejectCardUponTooHighWithdraw_id30);
		bloc_alt_id27_alter.add(requestTakeCard_id31);
		
		// adds for alt_id27
		Alt alt_id27= new Alt();
		alt_id27.add(bloc_alt_id27_conseq);
		alt_id27.add(bloc_alt_id27_alter);
		
		/* add(s) for getMoney_id21 */
		bloc_getMoney_id21.add(remove_id22);
		bloc_getMoney_id21.add(alt_id27);
		
		// TODO ca erreur signaler Jean a verifier
		//Call getMoney_id21 = new Call(new Statement("S" + i++,atm,new Method("getMoney",new ArrayList<ObjectInstance>(),atmClass),atm), bloc_getMoney);
		Call getMoney_id21 = new Call(new Statement("S" + i++,atm,new Method("getMoney",new ArrayList<ObjectInstance>(),atmClass),atm), bloc_getMoney_id21);
		
		/* add(s) for withdrawMoney_id20 */
		bloc_withdrawMoney_id20.add(getMoney_id21);
		
		// TODO ca erreur signaler Jean a verifier
		//Call withdrawMoney_id20 = new Call(new Statement("S" + i++,ihm,new Method("withdrawMoney",new ArrayList<ObjectInstance>(),atmClass),atm), bloc_withdrawMoney);
		Call withdrawMoney_id20 = new Call(new Statement("S" + i++,ihm,new Method("withdrawMoney",new ArrayList<ObjectInstance>(),atmClass),atm), getMoney_id21);
		
		// add(s) for bloc_alt_id17_alter
		bloc_alt_id17_alter.add(withdrawMoney_id20);
		
		// adds for alt_id17
		Alt alt_id17= new Alt();
		alt_id17.add(bloc_alt_id17_conseq);
		alt_id17.add(bloc_alt_id17_alter);
		
		//add(s) for loop_id14
		bloc_loop_id14.add(enterPassword_id15);
		bloc_loop_id14.add(alt_id17);
		Loop loop_id14 = new Loop(bloc_loop_id14);
		
		// add(s) for bloc_alt_id9_alter
		bloc_alt_id9_alter.add(loop_id14);
		
		// adds for alt_id9
		Alt alt_id9= new Alt();
		alt_id9.add(bloc_alt_id9_conseq);
		alt_id9.add(bloc_alt_id9_alter);
		
		// add(s) for bloc_alt_id5_alter
		bloc_alt_id5_alter.add(requestPass_id8);
		bloc_alt_id5_alter.add(alt_id9);
		
		// adds for alt_id5
		Alt alt_id5= new Alt();
		alt_id5.add(bloc_alt_id5_conseq);
		alt_id5.add(bloc_alt_id5_alter);
		
		/* add(s) for insertCard_id2 */
		bloc_insertCard_id2.add(checkCard_id3);
		bloc_insertCard_id2.add(alt_id5);
		
		// TODO ca erreur signaler Jean a verifier
		//Call insertCard_id2 = new Call(new Statement("S" + i++,ihm,new Method("insertCard",new ArrayList<ObjectInstance>(),atmClass),atm), bloc_insertCard);
		Call insertCard_id2 = new Call(new Statement("S" + i++,ihm,new Method("insertCard",new ArrayList<ObjectInstance>(),atmClass),atm), bloc_insertCard_id2);
		
		/* add(s) for displayMainScreen_id1 */
		bloc_displayMainScreen_id1.add(insertCard_id2);
		
		// TODO ca erreur signaler Jean a verifier
		//Call displayMainScreen_id1 = new Call(new Statement("S" + i++,atm,new Method("displayMainScreen",new ArrayList<ObjectInstance>(),ihmClass),ihm), bloc_displayMainScreen);
		Call displayMainScreen_id1 = new Call(new Statement("S" + i++,atm,new Method("displayMainScreen",new ArrayList<ObjectInstance>(),ihmClass),ihm), insertCard_id2);
		ArrayList<Block> entry_point_id32 = new ArrayList<Block>();
entry_point_id32.add(displayMainScreen_id1);
		return new Main(entry_point_id32, actors, 200);
	} 

	public static void main(String[] agrs) {
		Main sd=create();
		boolean ok=sd.saveModel("ATM_Factory");
		if (ok){
			sd.genereAllTraces("ATM_Factory", 100);
		}
		
	}
}
